//js
$(function(){
// var _startMouseX;
// var _startContainerX;
// var _isMoving = false;
var _showFullContent = false;

function init(){
	//console.log('hello world!');


	// jQuery(window).on( "swipeleft", onSwipeLeft);
	// jQuery(window).on( "swipeleft", onSwipeRight);
	// $('#wr-container').bind('touchstart mousedown', onContainerTouchStart);
	// $('#wr-container').bind('touchmove mousemove', onContainerTouchMove);
	// $('#wr-container').bind('touchend mouseup mouseleave', onContainerTouchEnd);

	
	var gridWidth = 540 + 48;
	var gridHeight = 810;
	Draggable.create("#wr-container", {
	    type:"x",
	    edgeTolerance:0.25,
	    edgeResistance:0.85,
	    bounds: {minX:0, maxX:-5400},
	    lockAxis:true,
	    throwProps:true,
	    zIndexBoost:false,
	    snap: {
        x: function(endValue) {
            return Math.round(endValue / gridWidth) * gridWidth;
        },
        y: function(endValue) {
            return Math.round(endValue / gridHeight) * gridHeight;
        }
	    }
	});

	$('#wcb-btn-full').click(onFullContentClick);
}

function onFullContentClick(e) {
	// body...
	_showFullContent = !_showFullContent;
	$('#wcb-btn-full img').toggleClass('wc-body-rotate');
	//show
	if(_showFullContent){
		$('#wcb-article').addClass('wc-body-open');
		$('#wcb-btn-full span').text('缩略全文');
		// TweenLite.to("#wcb-article", 0.5, {height:"50%", ease:Power2.easeInOut});
	}else{
		$('#wcb-btn-full span').text('展开全文');
		$('#wcb-article').removeClass('wc-body-open');
	}
}

/*
function onContainerTouchStart(e) {
	// console.log(e.clientX);
	_startMouseX = e.clientX || e.originalEvent.touches[0].clientX;
	_startContainerX = $('#wr-container').position().left;
	_isMoving = true;
}

function onContainerTouchMove(e) {
	var x = e.clientX || e.originalEvent.touches[0].clientX;
	var deltaX = x - _startMouseX;
	var cx;
	if(_isMoving){
		$('#wr-container').css('left', _startContainerX + deltaX);
		console.log(deltaX, _startContainerX);
	}
}

function onContainerTouchEnd(e) {
	_isMoving = false;
	console.log('moved out!');
}*/

init();
});